package com.p2p.system.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.p2p.model.entity.Account;
import com.p2p.model.entity.Userbankinfo;
import com.p2p.system.common.Result;
import com.p2p.system.service.UserbankinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户银行信息表 前端控制器
 * </p>
 *
 * @author 黄旭彬
 * @since 2023-12-16
 */
@CrossOrigin
@RestController
@Api(tags = "用户银行卡管理接口")
@RequestMapping("/system/userbankinfo")
public class UserbankinfoController {

    @Autowired
    private UserbankinfoService userbankinfoService;

    @ApiOperation("获取用户银行卡信息")
    @PostMapping("/getAccountByIdName")
    public Result getAccountByIdName(@RequestBody Userbankinfo userbankinfo ){
        Long id = userbankinfo.getId();
//        Userbankinfo userbankinfo1 = this.userbankinfoService.selectBankinfoById(id);
        List<Userbankinfo> list = this.userbankinfoService.selectBankinfosById(id);
        return Result.ok(list);
    }

    @ApiOperation("添加用户银行卡")
    @PostMapping("/addBankinfo")
    public Result addBankinfo(@RequestBody Userbankinfo userbankinfo){
        boolean save = this.userbankinfoService.save(userbankinfo);
        if (save){
            return Result.ok();
        }else {
            return Result.fail();
        }
    }

}

